package com.ludomancy.archeologyrpg.entities;

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Point;

import com.ludomancy.archeologyrpg.GameTheme;
import com.ludomancy.archeologyrpg.Entity;
import com.ludomancy.archeologyrpg.Game;

public class Swamp extends Entity
{
	private int exploreMax = Game.discretize(1000); // 1 unit each 2 seconds
	private int exploreTime = 0;
	private boolean consumed = false;
	public int health = 100;
	
	public Swamp(Point p)
	{
		super(p);
	}
	
	public void loseHealth(int amount)
	{
		health = Math.max(0, health-amount);
		if(health == 0)
		{
			dead = true;
		}
	}
	
	public boolean isActive()
	{
		return !consumed;
	}
	
	public String getInfo()
	{
		return "Local forage than appears to consume methane";
	}

	public void paint(Graphics g, int x, int y)
	{
		paintDefaultIcon(g, SWAMP, x, y);
	}
	
	public void update(boolean running, boolean activated)
	{
		if(running)
		{
			if(activated)
			{
				exploreTime++;
				if(exploreTime == exploreMax)
				{
					exploreTime = 0;
					Game.game.showHint("Some of the leaves seem chewed. Apparently something has been feeding off it.");
					consumed = true;
				}
			}
		}
	}

	public void paintInfo(Graphics g)
	{
		g.setColor(Color.BLUE);
		g.setFont(GameTheme.theme.tinyFont);
		if(exploreTime > 0)
		{
			GameTheme.theme.paintBar(g, px, py+Game.ENTITY_TILE_SIZE, exploreTime, exploreMax);
		}
	}

	public String getActionVerb()
	{
		return "Investigate";
	}
}
